package mobi.greenplate.theweb.converter;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
import mobi.greenplate.theweb.domain.User;


@XmlRootElement(name="user-list")
public class UserListConverter {

    private final List<User> entities;

    public UserListConverter() {
        this.entities=new ArrayList<User>();
    }
    
    public UserListConverter(List<User> entities) {
        this.entities = entities;
    }

    @XmlElement
    public List<UserConverter> getUser(){
        final List<UserConverter> list = new ArrayList<UserConverter>();
        for (User user : entities) {
            list.add(new UserConverter(user));
        }
        return list;
    }

    @XmlTransient
    public List<User> getEntities(){
        return Collections.unmodifiableList(this.entities);
    }

}


